import moment from 'moment'
moment.locale('zh-cn')

export const relativeTime = ({ publishTime }) => {
  const dateNow = moment().subtract(1, 'days').format('YYYY-MM-DD')
  const publishDate = moment(publishTime).format('YYYY-MM-DD')
  if (moment(publishDate).isBefore(dateNow)) {
    return `${moment(publishTime).format('YYYY-MM-DD HH:mm:ss')}`
  } else {
    return `发布时间：${moment(publishTime).fromNow()}`
  }
}